package com.zslc.securitymonitoring.util;

import javax.validation.constraints.NotNull;
import java.util.HashMap;
import java.util.Map;


/**
 * @description 分页查询请求
 * @author Gaoyc
 * @date  2024/4/2 11:10:37
 **/
public class PageRequest {
    /**
     * 当前页码
     */
    @NotNull
    private Integer page;
    /**
     * 每页数量
     */
    @NotNull
    private Integer pageSize;


    /**
     * 查询参数
     */
    @NotNull
    private Map<String, Object> params = new HashMap<>();

    public PageRequest() {
    }
    public PageRequest(int page, int pageSize) {
        this.page = page;
        this.pageSize = pageSize;
    }

    public Integer getPage() {
        if(page == null){
            page = 0;
        }
        return page;
    }
    public void setPage(Integer page) {
        this.page = page;
    }
    public Integer getPageSize() {
        if(pageSize == null || pageSize == -1){
            pageSize = Integer.MAX_VALUE;
        }
        return pageSize;
    }
    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }
    public Map<String, Object> getParams() {
        return params;
    }
    public void setParams(Map<String, Object> params) {
        this.params = params;
    }
    public Object getParam(String key) {
        return getParams().get(key);
    }
}
